package com.example.demo2_review.design_pattern.behavioral_patterns.strategy_pattern;

/**
 * @Author zwp14
 * @create 2024/6/25 1:21
 * @description 使用策略模式
 */
public class StrategyPatternDemo {
    public static void main(String[] args) {
        Context contextAdd = new Context(new OperationAdd());
        System.out.println("context.executeStrategy(1,2) = "
                + contextAdd.executeStrategy(1, 2));

        Context contextSubtract = new Context(new OperationSubtract());
        System.out.println("contextSubtract.executeStrategy(3,4) = "
                + contextSubtract.executeStrategy(3, 4));

        Context contextMultiply = new Context(new OperationMultiply());
        System.out.println("contextMultiply.executeStrategy(5,6) = "
                + contextMultiply.executeStrategy(5, 6));
    }
}
